#@layoutT('编辑表单')
#define main()
    <div class='layui-row f-index-toolbar'>
        <div class='layui-col-xs12'>
            <div class="layui-btn-group">
                <button id='addBtn_' class="layui-btn layui-btn-normal layui-btn-sm" onclick="save()">
                    <i class="layui-icon">&#xe605;</i> 保存
                </button>
                <button id='closeWinBtn' class="layui-btn  layui-btn-normal layui-btn-sm">
                    <i class="layui-icon">&#x1006;</i> 关闭
                </button>
            </div>
        </div>
    </div>

    <form action="javascript:void(0)" class="layui-form layui-form-pane f-form" method="post" id="saveForm" lay-filter='saveForm'>
        <input class='layui-input' id='id' type="hidden" name='id' value='#(id??)' >
        <!-- 文本编辑器 -->
        <div class="layui-row layui-col-space1 task-row"style="height: 100%">
            <textarea id="editor" style="display: block;"></textarea>
            <textarea id="ddlSql" name="template_view" style="display: none;"></textarea>
        </div>
        <button id="submitBtn_" class="layui-hide"></button>
    </form>
    #define js()
    <script type="text/javascript">
        var layedit;
        var layeditIndex;
        layui.use('layedit', function(){
            layedit = layui.layedit;
            //建立编辑器
            layeditIndex=layedit.build('editor',{
                tool: []
            });
             $(".layui-layedit .layui-unselect.layui-layedit-tool")
            //     .append('<i class="layui-icon layui-icon-add-1" title="添加页面模板" onclick="generateTextArea(\'add\')"></i>')
            //     .append('<i class="layui-icon layui-icon-edit" title="修改页模板" onclick="generateTextArea(\'edit\')"></i>')
            //     .append('<i class="layui-icon layui-icon-table" title="列表页模板" onclick="generateTextArea(\'index\')"></i>');

            $(".layui-layedit-iframe").hide();
        });

        function generateTextArea(temp) {
            $.post("#(path)/portal/form/viewTemp?temp="+temp,function(data){
                ddlSql.setValue(data);
            });
        };

        function review(){
            var html=ddlSql.getValue();

            $.ajax({
                url:"#(path)/portal/form/viewTemp/toReview",
                type:"POST",
                data:{
                    "html":html
                },
                success:function(ret){
                    openDialog("预览模板","#(path)/portal/form/viewTemp/review",false,null,null,null);
                }
            });
        }

        function save(){
            $("#submitBtn_").click();
        }

    </script>
    #end

    <style>
        .layui-container-fluid {
            margin: 10px;
            background: #ffffff;
            padding: 10px;
        }

        .f-index-toolbar {
            padding: 0px 0px 10px 0px;
        }
    </style>
#end

<!-- 保存数据 -->
#define layuiFunc()
  var saveUrl="#(path)/portal/form/view/updateFileView";
#end
